package guo.mybatis.session;

import guo.mybatis.binding.MapperProxy;
import guo.mybatis.config.Configuration;
import guo.mybatis.executor.SimpleExecutor;

import java.lang.reflect.Proxy;

public class SqlSession {

	private Configuration configuration;
	private SimpleExecutor simpleExecutor;

	public SqlSession(Configuration configuration, SimpleExecutor simpleExecutor) {
		this.configuration = configuration;
		this.simpleExecutor = simpleExecutor;
	}

	public Configuration getConfiguration() {
		return configuration;
	}

	public <T> T getMapper(Class<T> type) {
		return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type},new MapperProxy<>(this,type));
	}
}

